package y23.Oct;

import java.util.*;

public class shiyan4 {
    static class Student{
        private String name;
        private Integer[] kScore = new Integer[4];
    }
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Map<String, Integer> k = new HashMap<>();
        k.put("Java程序设计", 0);
        k.put("数据库原理", 1);
        k.put("数据结构", 2);
        k.put("算法设计与分析", 3);
        List<Student> studentList = new ArrayList<>();
        for (int i = 0; i < 6; i++) {
            System.out.printf("请输入第%d名学生姓名：", i + 1);
            Student student = new Student();
            student.name = scanner.nextLine();
            for (int j = 0; j < 4; j++)
                student.kScore[j] = getScore();
            studentList.add(student);

        }
        System.out.print("请输入学生姓名：");
        String studentName = scanner.nextLine();
        for (int i = 0; i < studentList.size(); i++) {
            if (studentName.equals(studentList.get(i).name)) {
                System.out.print(studentName + " ");
                for (String key : k.keySet()) {
                    System.out.print("  " + key + "：" + studentList.get(i).kScore[k.get(key)]);
                }
            }
        }
        System.out.println("请输入一门课程");
        String kName = scanner.nextLine();
        double sum = 0;
        int maxS = 0;
        int minS = 100;
        int count = 0;
        System.out.print("不及格的人：");
        for (int i = 0; i < studentList.size(); i++) {
            int score = studentList.get(i).kScore[k.get(kName)];
            if (score < 60){
                System.out.print(" " + studentList.get(i).name);
                count++;
            }
            sum += score;
            maxS = Math.max(maxS,score);
            minS = Math.min(minS,score);
        }
        if (count == 0){
            System.out.print( "无");
        }
        double p = sum / 6;
        System.out.println("平均分：" + p + " 最高分：" + maxS + " 最低分：" + minS);
    }

    private static Integer getScore() {
        return new Random().nextInt(100);
    }
}
